<form class="layui-form" action="{:url()}" method="post" id="editForm">
    <div class="layui-form-item">
        <label class="layui-form-label">订单号</label>
        <div class="layui-input-inline">
            <input type="text" data-disabled class="layui-input field-orders_id" name="orders_id" disabled="disabled">
        </div>
    </div>

    
    <div class="layui-form-item">
        <label class="layui-form-label">物流单号</label>
        <div class="layui-input-inline">
            <input type="text" data-disabled class="layui-input field-waybill_id" name="waybill_id">
        </div>
    </div>


    
    <div class="pop-bottom-bar hisi-footer">
        <input type="hidden" name="id" value="{$formData['id']}">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit" lay-data="{pop: true, refresh: true}">确认发货</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>
{include file="system@block/layui" /}
<script>
var s = "";
layui.use(['func'], function() {
    layui.func.assign({:json_encode($formData)});
});

layui.use(['form', 'layedit'], function () {
    var form=layui.form,layedit=layui.layedit;
    var index1 = layedit.build('LAY_demo1', {
            tool: ['strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right'],
            height: 200
        });
});


// 动态 增删 规格信息
var i=0;
$('#pihao').on('click', '.add', function() {
    i++;
    var $ = layui.jquery;
    var form = layui.form
    $.ajax({
        url:"{:url('getOptions')}",
        data:{id:''},
        dataType:"json", //接口json格式
        success:function(data){
            var options = data.data;
            console.log(options);
            var html = `<div class="layui-form-item">`+
            `<label class="layui-form-label"><span class="x-red">*</span>批号及数量</label>`+
            `<div class="layui-inline specname" >`+
            ` <select name="pihao[name][]" class="field-pihao[name][]" type="select" lay-verify="required">`+
                options+
                `</select>`+
            `</div>`+
            `<div class="layui-inline">`+
            `<input type="text" name="pihao[num][]" placeholder="请输入批号数量"  autoComplete="off" class="layui-input">`+
            `</div>`+

            `<div class="layui-inline layui-show-xs-block"  style="margin-left: 45px;">`+
            `<a class="layui-btn layui-btn-xs add">添加</a>`+
            `<a class="layui-btn layui-btn-danger layui-btn-xs del">删除</a>`+
            `</div>`+
            `</div>`;
            //添加到表格最后
            $('#pihao').append(html);
            form.render('select');
        },
        error:function(data){
            layer.alert(data.msg);
            // layer.alert(JSON.stringify(data), {
            //     title: data
            // });
        }
    });

    
});

// 删除规格
$('#pihao').on('click', '.del', function() {

if ($('#pihao div label').length === 1) {
    layer.msg('只有一条不允许删除。', {
        time : 2000
    });
} else {
    //删除当前按钮所在的tr
    $(this).closest('div .layui-form-item').remove();
}
});
</script>
<!--
/**
 * editor 富文本编辑器
 * @param array $obj 编辑器的容器ID
 * @param string $name [为了方便大家能在系统设置里面灵活选择编辑器，建议不要指定此参数]，目前支持的编辑器[ueditor,umeditor,ckeditor,kindeditor]
 * @param string $upload [选填]附件上传地址
 */
-->
{:editor(['UMeditor1', 'UMeditor2'])}
{:editor(['kindeditor1', 'kindeditor2'], 'kindeditor')}
{:editor(['UEditor1', 'UEditor2'], 'ueditor')}
{:editor(['ckeditor', 'ckeditor2'], 'ckeditor')}